/*
 * ParamSimple.java
 * 
 * Copyright 2004 Christoph Csallner and Yannis Smaragdakis.
 */
package edu.gatech.cc.cnc.params;

import static edu.gatech.cc.jcrasher.Assertions.notNull;
import edu.gatech.cc.jcrasher.plans.expr.Expression;
import edu.gatech.cc.jcrasher.plans.expr.Variable;
import edu.gatech.cc.jcrasher.plans.stmt.LocalVariableDeclarationStatement;

/**
 * Represents the simple types that are not treated separately:
 * float, double, character.
 * 
 * @author csallner@gatech.edu (Christoph Csallner)
 */
public class ParamSimple<T> extends Param<T> {

  protected Class<T> returnType;
  
	
	/**
	 * Constructor
	 */
	public ParamSimple(String string, Class<T> returnType) {
		super(string);

    this.returnType = notNull(returnType);
	}
	
	@Override
	public String getTypeName() {
		return returnType.getName();
	}
	
	@Override
	public Class<T> getType() {
		return returnType;
	}

	/**
	 * Ignore, not yet supported.
	 */
	@Override
	public void constrain(String constLHS, int relation2) {
		/* We do not have any constraint solver for float, double */
	}

	/**
	 * Ignore, not yet supported.
	 */
	@Override
	public void constrain(int relation2, String constRHS){
		/* We do not have any constraint solver for float, double */
	}
	
	/**
	 * Ignore, not yet supported.
	 */
	@Override
	public void constrain(int relation2, Param rhs) {
		/* We do not have any constraint solver for float, double */
	}  
  
  @Override
  public LocalVariableDeclarationStatement<? extends T> getPlan() {
    Variable<T> variable = nextID(returnType);
    Expression<? extends T> value = 
      JCrasherPlanner.instance().getRandom(returnType, testeeType); 
    return new LocalVariableDeclarationStatement<T>(variable, value);
  }
}
